package com.henu.engineer.controller.student

import com.alibaba.fastjson.JSONArray
import com.alibaba.fastjson.JSONObject
import com.henu.engineer.StringUtils
import com.henu.engineer.dao.entity.student.StudentComprehensiveScore
import com.henu.engineer.dao.entity.student.StudentCourseMethod
import com.henu.engineer.dao.entity.student.StudentScore
import com.henu.engineer.service.LoginService
import com.henu.engineer.service.student.StudentScoreService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.web.servlet.server.Session
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.servlet.http.HttpSession

/**
 * @author noexcept
 * @date 2021/8/8 22:54
 */
@RestController
@RequestMapping("/st")
class StudentScoreController {

    @Autowired
    private lateinit var service: StudentScoreService

    @Autowired
    lateinit var loginService: LoginService

    /**
     * 返回学生各课程的试卷成绩
     * @param studentId
     * @return
     */
    @GetMapping("/scores")
    fun getStudentScores(): String {
        val res = JSONObject()
        res["code"] = 1
        res["msg"] = "SUCCESS"
        res["data"] = service.getStudentAllTestPaperScores(loginService.currentUserId!!)
        return res.toJSONString();
    }

    /**
     * 返回某学生所有所有课程的所有考核方式得分和综合成绩
     */
    @GetMapping("/courseMethodScore")
    fun getCourseMethodScore(): String {
        val res = JSONObject()
        res["code"] = 1
        res["msg"] = "SUCCESS"
        res["data"] = service.getMethodScore(loginService.currentUserId!!)
        return res.toJSONString()
    }

    /**
     * 返回学生所有课程的综合成绩
     */
    @GetMapping("/comprehensiveScore")
    fun getComprehensiveScore(): String {
        val res = JSONObject()
        res["code"] = 1
        res["msg"] = "SUCCESS"
        res["data"] = service.getComprehensiveScore(loginService.currentUserId!!)
        return res.toJSONString()
    }
}